package com.h117121.fashionshop.validator;

import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

import com.h117121.fashionshop.core.dom.Account;

public class LoginValidator implements Validator {
	@SuppressWarnings("rawtypes")
	@Override
	public boolean supports(Class clazz) {
		return Account.class.isAssignableFrom(clazz);
	}

	@Override
	public void validate(Object target, Errors errors) {
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "userName",
				"required.userName", "Vui lòng nhập tên tài khoản");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "userPassword",
				"required.userPassword", "Vui lòng nhập mật khẩu");
	}
}
